package org.ben.xintoucloud.javase.exception;

import java.io.IOException;
import java.util.Scanner;

/**
 * @Author: Ben
 * @Date: 2019/7/11 15:22
 */
public class Exception {

    public int getInt(String string)throws IOException{
//        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        Scanner scanner=new Scanner(System.in);
           int a=0;
        while(true) {
            try {
                System.out.println("请输入"+string);
                 a = scanner.nextInt();
                break;
            } catch (java.lang.Exception e) {
                System.out.println("您的输入有误，请重新输入");
                scanner.nextInt();
            }
        }
        return a;
    }


    public int judgment(int a,int b){
        return a/b;
    }
    public int chu() throws IOException {
        Exception exception=new Exception();
        return exception.getInt("除数");

    }
    public int yu()throws IOException{
        Exception exception=new Exception();
       return exception.getInt("被除数");
    }
    public static void main(String[] args)throws IOException {
       Exception exception=new Exception();
       while (true) {
           try {
               System.out.println(exception.judgment(exception.chu(), exception.yu()));
                break;
           } catch (java.lang.Exception e) {
               System.out.println("程序异常，请重新输入");
           }
       }

    }
}
